// var Promise = require("../PromiseAPlus");
var promisesAplusTests = require("promises-aplus-tests");
var assert = require("assert");

var adapter = {
  resolved: function(val) {
    return Promise.resolve(val);
  },
  rejected: function(val) {
    return Promise.reject(val);
  },
  deferred: function() {
    var res, rej;
    var promise = new Promise(function(r1, r2) {
      res = r1;
      rej = r2;
    });

    return {
      promise: promise,
      resolve: res,
      reject: rej
    };
  },
  defineGlobalPromise: function(global) {
    global.Promise = Promise;
    global.assert = assert;
  },
  removeGlobalPromise: function(global) {
    delete global.Promise;
  }
};

promisesAplusTests(adapter, function(err) {
  // All done; output is in the console. Or check `err` for number of failures.
  console.log(err === null ? "success" : err);
});
